#include "deck.h"
#include <kdebug.h>




Deck::Deck(long seed, QObject* parent)
    : AbstractDeck(parent)
{
    mRandom.setSeed(seed);
    shuffle();
}

// Draw a card from the deck
int Deck::drawCard()
{
    if (m_cards.size() < 1)
    {
        kFatal() << "No more cards to draw from card deck";
    }
    int card = m_cards.takeFirst();
    return card;
}



void Deck::shuffle() {
    m_cards.clear();

    int l_cardNumber=Deck::cardsNumber();

    for (int i=0; i<l_cardNumber; i++)
    {
        m_cards.append(i);
    }

    for (int i=0; i<l_cardNumber; i++)
    {
        int c1 = mRandom.getLong(l_cardNumber);
        int c2 = mRandom.getLong(l_cardNumber);
        //kDebug() << "Swapping " << c1 << " and " << c2;
        m_cards.swap(c1, c2);
    }
}
